// ignore_for_file: file_names, slash_for_doc_comments, must_call_super, unnecessary_overrides, override_on_non_overriding_member, must_be_immutable, prefer_const_constructors, sized_box_for_whitespace, avoid_unnecessary_containers, avoid_print

import 'package:flutter/material.dart';
import 'package:mybaseplus/base/abstract/IFFR.dart';
import 'package:mybaseplus/base/abstract/IFFRefresh.dart';
import 'package:mybaseplus/base/abstract/IFFScaffold.dart';
import 'package:mybaseplus/base/widget/layout/FFLineContainer.dart';
import 'package:mybaseplus/base/widget/layout/FFTextButton.dart';
import 'package:mybaseplus/base/widget/page/FFScaffold.dart';
import 'package:mybaseplus/base/tool/extension/FFListExt.dart';


class TemplateNormalPage extends FFScaffold {
  String? name;

  TemplateNormalPage({
    Key? key,
    this.name,
  }) : super(key: key);

  @override
  TemplateNormalPageState createState() => TemplateNormalPageState();
}

class TemplateNormalPageState extends FFScaffoldState with MFFScaffold {
  /**固定写法 */
  @override
  IFFScaffold get iffScaffold => this;

  @override
  TemplateNormalPage get widget => super.widget as TemplateNormalPage;

  @override
  IFFRefresh? get iffRefresh => refresh;
  late TemplateNormalPageRefresh refresh =
      TemplateNormalPageRefresh(state: this);
  /**固定写法end */

  @override
  void ffInitState() {
    super.ffInitState();
  }

  @override
  Widget? ffNavi(BuildContext context) {
    // return AppNavi.createNavi(
    //   context,
    //   title: "Title",
    //   actions: [
    //     DueNaviAction(
    //         value: 'assets/images/detail/settings_24px.png',
    //         type: DueNaviActionType.img,
    //         onClick: () {}),
    //     DueNaviAction(
    //         type: DueNaviActionType.img,
    //         value: 'assets/images/home/road.png',
    //         onClick: () async {})
    //   ],
    // );
  }

  @override
  Widget? ffBody(BuildContext context) {
    List<Widget> slivers = [
      SliverToBoxAdapter(
        child: Container(
          child: FFLineContainer(
            children: [
              FFTextButton(
                notes: "文本展示",
                padding: EdgeInsets.symmetric(vertical: 10, horizontal: 10),
                unconstrainedBox: true,
                text: "这是按扭",
                color: Colors.pink,
                onClick: () {
                  print("点击我了");
                },
              ),
            ],
          ),
        ),
      ),
    ];
    return CustomScrollView(slivers: slivers);
  }
}

class TemplateNormalPageRefresh with MFFRefresh {
  TemplateNormalPageState state;

  TemplateNormalPageRefresh({required this.state});

  @override
  bool? ffCanRefreshHead() {
    return true;
  }

  @override
  ffRefresh(bool isHead) {
    ffRefreshResult(isHead, test, state);
  }

  //具体请求业务
  Future<IFFR> test(IRefreshParam? iRefreshParam) async {
    List? list;
    await Future.wait([
      //HomeApi.index_recentlyPlayed(),
    ]).then((value) {
      list = value;
    });

    IFFR? r = list?.safeValue(0);
    return r ?? R(rStatus: RStatus.result);
  }
}
